package cn.study.controller;


import cn.study.entity.*;
import cn.study.service.StudyEmployeeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import sun.security.util.Password;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 员工表 前端控制器
 * </p>
 *
 * @author qiao
 * @since 2020-06-22
 */
@Controller
@RequestMapping("/study-employee")
public class StudyEmployeeController {

    @Resource
    StudyEmployeeService studyEmployeeService;

    @GetMapping("/study_person")
    public String details(Model model, Integer id) {
        List<StudyEmployee> emplist = studyEmployeeService.getList(id);
        model.addAttribute("emplist", emplist);
        return "study_person";
    }

    //验证密码
    @ResponseBody
    @PostMapping("/verifypwd")
    public boolean verifypwd(@RequestParam String pwd, @RequestParam Integer id, Model model) {
        StudyEmployee studyEmployee = studyEmployeeService.getById(id);
        if (studyEmployee.getPassword().equals(pwd)) {
            return true;
        }
        return false;
    }

    @ResponseBody
    @PostMapping("/courseupd")
    public String courseupd(String pwd,Integer id) {
        StudyEmployee studyEmployee=studyEmployeeService.getById(id);
        studyEmployee.setPassword(pwd);
        boolean bl = studyEmployeeService.updateById(studyEmployee);
        if (!bl) {
            return "修改失败";
        }
        return "修改成功！";
    }
}


